﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DB.MongoDB.Model
{
    public enum CompareType
    {
        /// <summary>
        /// =
        /// </summary>
        equal = 1,
        /// <summary>
        /// !=
        /// </summary>
        notEqual = -1,
        /// <summary>
        /// >
        /// </summary>
        bigger = 2,
        /// <summary>
        /// <
        /// </summary>
        less = -2,
        /// <summary>
        /// >=
        /// </summary>
        biggerEqual = 3,
        /// <summary>
        /// <=
        /// </summary>
        lessEqual = -3,
        /// <summary>
        /// in ()
        /// </summary>
        contain = 4,
        /// <summary>
        /// not in ()
        /// </summary>
        notContain = -4
    }
    public enum FilterType
    {
        and = 1,
        or = 0
    }
    public class FilterRule
    {
        public FilterRule(string field = null, string value = null, CompareType compareType= CompareType.equal)
        {
            this.CompareType = compareType;
            this.Field = field;
            this.Value = value;
        }
        public CompareType CompareType { get; set; }
        public string Field { get; set; }
        public string Value { get; set; }
    }

    public class FilterGroup
    {
        public FilterGroup()
        {
            FilterType = FilterType.and;
            FilterRules = new List<FilterRule>();
            FilterGroups = new List<FilterGroup>();
        }
        public FilterType FilterType { get; set; }

        public List<FilterRule> FilterRules { get; set; }

        public List<FilterGroup> FilterGroups { get; set; }
    }
}
